package com.example.springbott.controller;

import com.example.springbott.aspactJ.OperationName;
import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketKeyword;
import com.example.springbott.bean.common.AdminKeywordListVO;
import com.example.springbott.bean.common.KeywordCreateBO;
import com.example.springbott.bean.common.KeywordListBO;
import com.example.springbott.service.AdminKeywordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 1784549954@qq.com
 * @since 2022/11/20 20:31
 */
@RestController
@RequestMapping("admin/keyword")
public class AdminKeWordController {

    @Autowired
    AdminKeywordService adminKeywordService;

    /**
     * 获取关键词信息
     * @param keywordListBO  page/limit/sort/order
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/20 21:24
     */
    @RequiresPermissions("admin:keyword:list")
    @RequestMapping("list")
    @OperationName("1")
    public BaseRespVo AdminKeywordList( KeywordListBO keywordListBO) {
        AdminKeywordListVO adminKeywordListVO = adminKeywordService.list(keywordListBO);
        return BaseRespVo.ok(adminKeywordListVO);
    }

    /**
     * 添加关键词
     * @param marketKeyword 
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/21 9:04 
     */
    @RequiresPermissions("admin:keyword:create")
    @PostMapping("create")
    @OperationName("1")
    public BaseRespVo AdminKeywordCreate(@RequestBody MarketKeyword marketKeyword){
        adminKeywordService.keywordCreate(marketKeyword);
        return BaseRespVo.ok(null);
    }

    /**
     * 编辑关键词信息
 * @param marketKeyword
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/21 9:07
     */
    @RequiresPermissions("admin:keyword:update")
    @PostMapping("update")
    @OperationName("1")
    public BaseRespVo AdminKeywordUpdate(@RequestBody MarketKeyword marketKeyword){
        adminKeywordService.keywordUpdate(marketKeyword);
        return BaseRespVo.ok(null);

    }

    /**
     * 逻辑删除删除关键字
 * @param marketKeyword
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/21 9:16
     */
    @RequiresPermissions("admin:keyword:delete")
    @PostMapping("delete")
    @OperationName("1")
    public BaseRespVo AdminKeywordDelete(@RequestBody MarketKeyword marketKeyword){
        adminKeywordService.keywordDelete(marketKeyword);
        return BaseRespVo.ok(null);
    }
}
